<template>
  <div class="service-container">
    <el-card class="table-card">
      <template #header>
        <div class="table-header">
          <h3>临时停车管理</h3>
          <div class="header-right">
            <el-button type="primary" @click="openEntryDialog" class="entry-btn">
              <el-icon><CaretRight /></el-icon>车辆入场
            </el-button>
            <div class="search-toggle-area">
              <el-button class="search-toggle-button" @click="toggleSearchBar">
                <el-icon><Search /></el-icon>
              </el-button>
              <el-form :inline="true" :model="queryParams" class="search-form" :class="{'is-hidden': !showSearchBar}" ref="queryForm">
                <el-form-item label="车牌号">
                  <el-input v-model="queryParams.plate_number" placeholder="请输入车牌号" clearable style="width: 100px;"></el-input>
                </el-form-item>
                <el-form-item label="支付状态">
                  <el-select v-model="queryParams.payment_status" placeholder="请选择支付状态" clearable style="width: 100px;">
                    <el-option label="未支付" value="未支付"></el-option>
                    <el-option label="已支付" value="已支付"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="时间筛选">
                  <el-select v-model="queryParams.time_type" placeholder="时间类型" style="width: 100px; margin-right: 5px;">
                    <el-option label="入场时间" value="entry_time"></el-option>
                    <el-option label="出场时间" value="exit_time"></el-option>
                  </el-select>
                  <el-date-picker
                    v-model="queryParams.time_value"
                    type="datetime"
                    placeholder="选择时间点"
                    value-format="YYYY-MM-DD HH:mm:ss"
                    style="width: 100px;"
                  ></el-date-picker>
                  <el-select v-model="queryParams.time_condition" placeholder="条件" style="width: 80px; margin-right: 5px;">
                    <el-option label="之后" value="after"></el-option>
                    <el-option label="之前" value="before"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="handleQuery">查询</el-button>
                  <el-button @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </template>

      <el-table 
        v-loading="loading" 
        :data="parkingRecords" 
        border 
        stripe 
        :header-cell-style="{background:'#f5f7fa', color:'#606266'}"
      >
        <el-table-column prop="parking_record_id" label="记录ID" width="80" align="center" />
        <el-table-column prop="plate_number" label="车牌号" width="120" align="center" />
        <el-table-column label="所属人" width="150" align="center">
          <template #default="scope">
            <span v-if="scope.row.user">
              {{ scope.row.user.name }}
              <el-tag size="small" type="success">员工</el-tag>
            </span>
            <span v-else-if="scope.row.visitor">
              {{ scope.row.visitor.name }}
              <el-tag size="small" type="warning">访客</el-tag>
            </span>
            <span v-else>临时车辆</span>
          </template>
        </el-table-column>
        <el-table-column prop="entry_time" label="入场时间" width="200" align="center" />
        <el-table-column prop="exit_time" label="出场时间" width="200" align="center">
          <template #default="scope">
            {{ scope.row.exit_time || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="停车时长" width="120" align="center">
          <template #default="scope">
            <span v-if="scope.row.parking_duration">
              {{ formatDuration(scope.row.parking_duration) }}
            </span>
            <span v-else-if="scope.row.exit_time">
              {{ calculateDuration(scope.row.entry_time, scope.row.exit_time) }}
            </span>
            <span v-else>
              进行中
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="payment_status" label="支付状态" width="100" align="center">
          <template #default="scope">
            <el-tag :type="scope.row.payment_status === '已支付' ? 'success' : 'warning'">
              {{ scope.row.payment_status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="120" align="center">
          <template #default="scope">
            <el-button 
              v-if="!scope.row.exit_time" 
              type="primary" 
              link 
              @click="openExitDialog(scope.row)"
            >
              出场
            </el-button>
            <el-button 
              v-if="scope.row.exit_time && scope.row.payment_status === '未支付'" 
              type="warning" 
              link 
              @click="handleReminder(scope.row)"
            >
              催缴
            </el-button>
            <el-button type="info" link @click="viewDetails(scope.row)">
              详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-empty v-if="parkingRecords.length === 0 && !loading" description="暂无停车记录" class="empty-data-placeholder"></el-empty>

      <div class="pagination-container">
        <el-pagination
          v-model:current-page="queryParams.page"
          v-model:page-size="queryParams.limit"
          :page-sizes="[10, 20, 50, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>

    <!-- 入场登记对话框 -->
    <el-dialog
      title="车辆入场"
      v-model="entryDialogVisible"
      width="500px"
      append-to-body
    >
      <el-form
        ref="entryFormRef"
        :model="entryForm"
        :rules="entryRules"
        label-width="100px"
      >
        <el-form-item label="车牌号" prop="plate_number">
          <el-input 
            v-model="entryForm.plate_number" 
            placeholder="请输入车牌号" 
            clearable
            @input="handlePlateNumberInput"
          />
        </el-form-item>
        <el-form-item label="入场时间" prop="entry_time">
          <el-date-picker 
            v-model="entryForm.entry_time" 
            type="datetime" 
            placeholder="选择入场时间"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item label="入口通道" prop="entry_channel">
          <el-select v-model="entryForm.entry_channel" placeholder="请选择入口通道" style="width: 100%">
            <el-option label="东门入口" value="东门入口"></el-option>
            <el-option label="南门入口" value="南门入口"></el-option>
            <el-option label="西门入口" value="西门入口"></el-option>
            <el-option label="北门入口" value="北门入口"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="费率(元/小时)" prop="fee_rate">
          <el-input-number 
            v-model="entryForm.fee_rate" 
            :min="0" 
            :precision="2"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item label="车辆信息" v-if="vehicleInfo">
          <el-descriptions :column="1" size="small" border>
            <el-descriptions-item label="车辆类型">{{ vehicleInfo.vehicle_type }}</el-descriptions-item>
            <el-descriptions-item label="所属人">
              <span v-if="vehicleInfo.user">
                {{ vehicleInfo.user.name }} <el-tag size="small" type="success">员工</el-tag>
              </span>
              <span v-else-if="vehicleInfo.visitor">
                {{ vehicleInfo.visitor.name }} <el-tag size="small" type="warning">访客</el-tag>
              </span>
            </el-descriptions-item>
          </el-descriptions>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="entryDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleEntrySubmit">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 出场结算对话框 -->
    <el-dialog
      title="车辆出场"
      v-model="exitDialogVisible"
      width="500px"
      append-to-body
    >
      <el-form
        ref="exitFormRef"
        :model="exitForm"
        :rules="exitRules"
        label-width="100px"
      >
        <el-form-item label="车牌号">
          <el-input v-model="exitForm.plate_number" disabled />
        </el-form-item>
        <el-form-item label="入场时间">
          <el-input v-model="exitForm.entry_time" disabled />
        </el-form-item>
        <el-form-item label="出场时间" prop="exit_time">
          <el-date-picker 
            v-model="exitForm.exit_time" 
            type="datetime" 
            placeholder="选择出场时间"
            style="width: 100%"
            @change="calculateParkingFee"
          />
        </el-form-item>
        <el-form-item label="出口通道" prop="exit_channel">
          <el-select v-model="exitForm.exit_channel" placeholder="请选择出口通道" style="width: 100%">
            <el-option label="东门出口" value="东门出口"></el-option>
            <el-option label="南门出口" value="南门出口"></el-option>
            <el-option label="西门出口" value="西门出口"></el-option>
            <el-option label="北门出口" value="北门出口"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="停车时长">
          <el-input v-model="exitForm.duration" disabled />
        </el-form-item>
        <el-form-item label="费率(元/小时)">
          <el-input v-model="exitForm.fee_rate" disabled />
        </el-form-item>
        <el-form-item label="应付金额(元)" prop="payable_amount">
          <el-input-number 
            v-model="exitForm.payable_amount" 
            :min="0" 
            :precision="2"
            disabled
            style="width: 100%"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="exitDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleExitSubmit">确定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 详情对话框 -->
    <el-dialog
      title="停车详情"
      v-model="detailsDialogVisible"
      width="600px"
      append-to-body
    >
      <el-descriptions :column="2" border v-if="currentRecord">
        <el-descriptions-item label="记录ID" :span="2">{{ currentRecord.parking_record_id }}</el-descriptions-item>
        <el-descriptions-item label="车牌号">{{ currentRecord.plate_number }}</el-descriptions-item>
        <el-descriptions-item label="车辆类型">{{ currentRecord.vehicle ? currentRecord.vehicle.vehicle_type : '-' }}</el-descriptions-item>
        <el-descriptions-item label="所属人" :span="2">
          <span v-if="currentRecord.user">
            {{ currentRecord.user.name }} <el-tag size="small" type="success">员工</el-tag>
          </span>
          <span v-else-if="currentRecord.visitor">
            {{ currentRecord.visitor.name }} <el-tag size="small" type="warning">访客</el-tag>
          </span>
          <span v-else>临时车辆</span>
        </el-descriptions-item>
        <el-descriptions-item label="入场时间">{{ currentRecord.entry_time }}</el-descriptions-item>
        <el-descriptions-item label="入口通道">{{ currentRecord.entry_channel }}</el-descriptions-item>
        <el-descriptions-item label="出场时间">{{ currentRecord.exit_time || '-' }}</el-descriptions-item>
        <el-descriptions-item label="出口通道">{{ currentRecord.exit_channel || '-' }}</el-descriptions-item>
        <el-descriptions-item label="停车时长">
          <span v-if="currentRecord.parking_duration">
            {{ formatDuration(currentRecord.parking_duration) }}
          </span>
          <span v-else-if="currentRecord.exit_time">
            {{ calculateDuration(currentRecord.entry_time, currentRecord.exit_time) }}
          </span>
          <span v-else>进行中</span>
        </el-descriptions-item>
        <el-descriptions-item label="费率(元/小时)">{{ currentRecord.fee_rate }}</el-descriptions-item>
        <el-descriptions-item label="应付金额(元)">{{ currentRecord.payable_amount ? `¥ ${currentRecord.payable_amount}` : '-' }}</el-descriptions-item>
        <el-descriptions-item label="支付状态">
          <el-tag :type="currentRecord.payment_status === '已支付' ? 'success' : 'warning'">
            {{ currentRecord.payment_status }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="支付时间" :span="2">{{ currentRecord.payment_time || '-' }}</el-descriptions-item>
      </el-descriptions>
       <template #footer>
        <div class="dialog-footer">
          <el-button @click="detailsDialogVisible = false">关闭</el-button>
          <el-button 
            v-if="currentRecord.exit_time && currentRecord.payment_status === '未支付'" 
            type="warning" 
            @click="handleReminder(currentRecord)"
          >
            催缴
          </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { CaretRight, Search } from '@element-plus/icons-vue';
import { 
  getParkingRecords, 
  createParkingRecord, 
  updateParkingRecord, 
  getVehicleByPlate 
} from '@/api/services';
import { createNotification } from '@/api/notifications';

const queryParams = reactive({
  page: 1,
  limit: 10,
  plate_number: '',
  payment_status: '',
  time_type: 'entry_time',
  time_condition: 'after',
  time_value: null
});

const parkingRecords = ref([]);
const total = ref(0);
const loading = ref(false);
const showSearchBar = ref(false);

const entryDialogVisible = ref(false);
const entryFormRef = ref(null);
const entryForm = reactive({
  plate_number: '',
  entry_time: new Date(),
  entry_channel: '',
  fee_rate: 5.00,
});
const vehicleInfo = ref(null);

const exitDialogVisible = ref(false);
const exitFormRef = ref(null);
const exitForm = reactive({
  parking_record_id: null,
  plate_number: '',
  entry_time: '',
  exit_time: new Date(),
  exit_channel: '',
  duration: '',
  fee_rate: 0,
  payable_amount: 0
});

const detailsDialogVisible = ref(false);
const currentRecord = ref({});

const entryRules = reactive({
  plate_number: [
    { required: true, message: '请输入车牌号', trigger: 'blur' },
    { pattern: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-Z0-9]{5,6}$/, message: '请输入正确的车牌号', trigger: 'blur' }
  ],
  entry_time: [{ required: true, message: '请选择入场时间', trigger: 'change' }],
  entry_channel: [{ required: true, message: '请选择入口通道', trigger: 'change' }],
  fee_rate: [{ required: true, message: '请输入费率', trigger: 'blur' }]
});

const exitRules = reactive({
  exit_time: [{ required: true, message: '请选择出场时间', trigger: 'change' }],
  exit_channel: [{ required: true, message: '请选择出口通道', trigger: 'change' }]
});

const toggleSearchBar = () => {
  showSearchBar.value = !showSearchBar.value;
};

const fetchParkingRecords = async () => {
  loading.value = true;
  try {
    const apiParams = {
      page: queryParams.page,
      limit: queryParams.limit,
      plate_number: queryParams.plate_number,
      payment_status: queryParams.payment_status,
    };

    if (queryParams.time_value && queryParams.time_type && queryParams.time_condition) {
      if (queryParams.time_type === 'entry_time') {
        if (queryParams.time_condition === 'after') {
          apiParams.start_date = queryParams.time_value;
        } else {
          apiParams.end_date = queryParams.time_value;
        }
      } else if (queryParams.time_type === 'exit_time') {
        if (queryParams.time_condition === 'after') {
          apiParams.exit_start_date = queryParams.time_value;
        } else {
          apiParams.exit_end_date = queryParams.time_value;
        }
      }
    }

    const response = await getParkingRecords(apiParams);
    if (response.data && response.data.code === 200) {
      parkingRecords.value = response.data.data.results;
      total.value = response.data.data.count;
    } else {
      ElMessage.error(response.data.message || '获取停车记录失败');
    }
  } catch (error) {
    console.error('获取停车记录失败:', error);
    ElMessage.error('获取停车记录失败');
  } finally {
    loading.value = false;
  }
};

const handleQuery = () => {
  queryParams.page = 1;
  fetchParkingRecords();
};

const resetQuery = () => {
  queryParams.plate_number = '';
  queryParams.payment_status = '';
  queryParams.time_type = 'entry_time';
  queryParams.time_condition = 'after';
  queryParams.time_value = null;
  handleQuery();
};

const handleCurrentChange = (val) => {
  queryParams.page = val;
  fetchParkingRecords();
};

const handleSizeChange = (val) => {
  queryParams.limit = val;
  queryParams.page = 1;
  fetchParkingRecords();
};

const formatDuration = (minutes) => {
  if (!minutes && minutes !== 0) return '-';
  const hours = Math.floor(minutes / 60);
  const mins = minutes % 60;
  return `${hours > 0 ? hours + '小时' : ''} ${mins > 0 ? mins + '分钟' : ''}`.trim() || '0分钟';
};

const calculateDuration = (entryTime, exitTime) => {
  if (!entryTime || !exitTime) return '-';
  const durationMs = new Date(exitTime) - new Date(entryTime);
  const durationMinutes = Math.floor(durationMs / (1000 * 60));
  return formatDuration(durationMinutes);
};

const handlePlateNumberInput = async () => {
  if (entryForm.plate_number && entryForm.plate_number.length >= 7) {
    try {
      const response = await getVehicleByPlate(entryForm.plate_number);
      vehicleInfo.value = response.data.data;
    } catch (error) {
      vehicleInfo.value = null;
    }
  } else {
    vehicleInfo.value = null;
  }
};

const openEntryDialog = () => {
  entryForm.plate_number = '';
  entryForm.entry_time = new Date();
  entryForm.entry_channel = '';
  entryForm.fee_rate = 5.00;
  vehicleInfo.value = null;
  if(entryFormRef.value) entryFormRef.value.resetFields();
  entryDialogVisible.value = true;
};

const handleEntrySubmit = () => {
  entryFormRef.value.validate(async (valid) => {
    if (!valid) return;
    try {
      await createParkingRecord(entryForm);
      ElMessage.success('车辆入场登记成功');
      entryDialogVisible.value = false;
      fetchParkingRecords();
    } catch (error) {
      ElMessage.error(error.response?.data?.message || '车辆入场登记失败');
    }
  });
};

const openExitDialog = (row) => {
  exitForm.parking_record_id = row.parking_record_id;
  exitForm.plate_number = row.plate_number;
  exitForm.entry_time = row.entry_time;
  exitForm.exit_time = new Date();
  exitForm.exit_channel = '';
  exitForm.fee_rate = row.fee_rate;
  if(exitFormRef.value) exitFormRef.value.resetFields();
  calculateParkingFee();
  exitDialogVisible.value = true;
};

const calculateParkingFee = () => {
  if (!exitForm.entry_time || !exitForm.exit_time) return;
  const entry = new Date(exitForm.entry_time);
  const exit = new Date(exitForm.exit_time);
  if (exit <= entry) {
    exitForm.duration = '出场时间需晚于入场时间';
    exitForm.payable_amount = 0;
    return;
  }
  const durationMs = exit - entry;
  const durationMinutes = Math.ceil(durationMs / (1000 * 60));
  const durationHours = durationMinutes / 60;
  exitForm.duration = formatDuration(durationMinutes);
  const billableHours = Math.ceil(durationHours);
  exitForm.payable_amount = parseFloat((billableHours * exitForm.fee_rate).toFixed(2));
};

const handleExitSubmit = () => {
  exitFormRef.value.validate(async (valid) => {
    if (!valid) return;
    try {
      await updateParkingRecord(exitForm.parking_record_id, {
        exit_time: exitForm.exit_time,
        exit_channel: exitForm.exit_channel,
      });
      ElMessage.success('车辆出场登记成功');
      exitDialogVisible.value = false;
      fetchParkingRecords();
    } catch (error) {
      ElMessage.error(error.response?.data?.message || '车辆出场登记失败');
    }
  });
};

const handleReminder = (row) => {
  ElMessageBox.confirm(`确认向车牌号为 ${row.plate_number} 的车主发送催缴通知？`, '催缴确认', {
    confirmButtonText: '确定发送',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    if (!row.user || !row.user.user_id) {
      ElMessage.error('无法发送催缴通知：该车辆未关联到任何用户。');
      return;
    }

    const payload = {
      title: `停车费催缴通知 - 车牌: ${row.plate_number}`,
      content: `尊敬的用户，您的车辆（车牌号: ${row.plate_number}）于 ${row.exit_time} 离场，产生一笔临时停车费用，金额为 ${row.payable_amount} 元，目前尚未支付。请您尽快前往用户端或小程序完成支付。`,
      message_type: '缴费提醒',
      specific_users: [row.user.user_id],
      is_draft: false,
    };

    try {
      await createNotification(payload);
      ElMessage.success('催缴通知已成功发送');
      if (detailsDialogVisible.value) {
        detailsDialogVisible.value = false;
      }
    } catch (error) {
      ElMessage.error('发送催缴通知失败，请稍后重试。');
      console.error('发送催缴通知失败:', error);
    }
  }).catch(() => {
    ElMessage.info('已取消发送');
  });
};

const viewDetails = (row) => {
  currentRecord.value = row;
  detailsDialogVisible.value = true;
};

onMounted(fetchParkingRecords);
</script>

<style scoped>
.service-container {
  padding: 20px;
  background-color: #f8f9fa;
  min-height: calc(100vh - 80px);
}

.table-card {
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.05);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.table-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* 搜索区域 */
.search-toggle-area {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.search-toggle-button {
  font-size: 20px;
  color: #606266;
  align-self: center;
  margin-right: 15px;
  transition: all 0.2s;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 10;
  margin-bottom: 0;
}

.search-toggle-button:hover {
  color: #409eff;
  background-color: rgba(64, 158, 255, 0.1);
  border-color: rgba(64, 158, 255, 0.2);
}

.search-form {
  max-width: 1000px;
  width: auto;
  overflow: hidden;
  transition: max-width 0.4s ease-in-out, opacity 0.4s ease-in-out, background-color 0.4s ease-in-out, box-shadow 0.4s ease-in-out, padding 0.4s ease-in-out, margin-left 0.4s ease-in-out, height 0.4s ease-in-out, min-height 0.4s ease-in-out;
  opacity: 1;
  background-color: transparent;
  border-radius: 8px;
  padding: 0 20px;
  box-shadow: none;
  pointer-events: auto;
  margin-left: 15px;
  white-space: nowrap;
  height: 35px;
  min-height: 35px;
}

.search-form.is-hidden {
  max-width: 0;
  opacity: 0;
  padding: 0;
  margin-left: 0;
  height: 0;
  min-height: 0;
  background-color: transparent;
  box-shadow: none;
  pointer-events: none;
}

:deep(.search-form .el-form-item) {
  margin-bottom: 0;
  margin-right: 15px;
  display: inline-flex;
  align-items: center;
}

:deep(.search-form .el-form-item__label) {
  padding-right: 8px;
}

:deep(.table-card .el-card__header) {
  background-color: #f9fafc;
  padding: 15px 20px;
}

:deep(.table-card .el-card__body) {
  padding: 20px;
}

.pagination-container {
  margin-top: 25px;
  display: flex;
  justify-content: flex-end;
  padding: 12px 15px;
  background-color: #f9fbfd;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.empty-data-placeholder {
  margin-top: 40px;
}

.entry-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

:deep(.el-input__inner) {
  border-color: #e0e5ed !important;
  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 6px;
}

:deep(.el-input__inner:focus) {
  border-color: rgba(64, 158, 255, 0.4) !important;
}

:deep(.el-input__inner::placeholder) {
  color: #aebccf;
}

:deep(.el-button--primary) {
  background-color: rgba(64, 158, 255, 0.1) !important;
  color: #606266 !important;
  border-color: rgba(64, 158, 255, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 6px;
}

:deep(.el-button--primary:hover) {
  background-color: rgba(64, 158, 255, 0.15) !important;
  border-color: rgba(64, 158, 255, 0.3) !important;
}

:deep(.el-button--default) {
  background-color: #ffffff !important;
  color: #606266 !important;
  border-color: #dcdfe6 !important;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 6px;
}

:deep(.el-button--default:hover) {
  background-color: #f7f9fa !important;
  border-color: #c8d3dd !important;
}

:deep(.el-button--danger) {
  background-color: rgba(245, 108, 108, 0.1) !important;
  color: #F56C6C !important;
  border-color: rgba(245, 108, 108, 0.2) !important;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  border-radius: 6px;
}

:deep(.el-button--danger:hover) {
  background-color: rgba(245, 108, 108, 0.15) !important;
  border-color: rgba(245, 108, 108, 0.3) !important;
}
</style> 